package com.lz.component;

import com.lz.component.filter.HeadersCORSFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * Created by lz on 2018/8/10.
 */
@Configuration
public class FilterConfig {

    //注册请求跨域过滤器
    @Bean
    public FilterRegistrationBean CORSFilter(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new HeadersCORSFilter());
        registrationBean.setUrlPatterns(Arrays.asList("/*"));
        return registrationBean;
    }
}
